package edu.gatech.cs2340.group7.wheresmystuffapp.model;

import android.content.Intent;
import edu.gatech.cs2340.group7.wheresmystuffapp.views.LocationMapView;

public class IReportItemPresenter {
	protected IReportItemView myView;
	protected DatabaseHelper helper;
	
	public IReportItemPresenter(IReportItemView view) {
		myView = view;
		helper = new DatabaseHelper(myView);
	}
	
	/**
	 * Checks to see if the reward is a valid amount and if so converts it to an int
	 * @param reward The user input reward amount
	 * @return The int value of the reward.  If the format was invalid or null, returns 0
	 */
	public int convertReward(String reward) {
		Integer out = 0;
		if(!reward.isEmpty()) {
			/*
			 * the amount can be listed as 67, 67., 89.10
			 */
			// TODO Should be replaced with regex
			if(reward.matches("[0-9]*")) {
				out = Integer.parseInt(reward);
			}
		}
		
		return out;
	}
	
	/**
	 * Opens a map view activity to allow the user to select a location
	 * @param activity 
	 * @return String of the location selected by the user
	 */
	public void selectLocation(String name, String description, String category, String activity) {
		Intent intent = new Intent(myView, LocationMapView.class);
		intent.putExtra("Name", name);
		intent.putExtra("Description", description);
		intent.putExtra("Category", category);
		intent.putExtra("Activity", activity);
		myView.startActivity(intent);
	}

	/**
	 * 
	 * @return
	 */
	public ItemLocation getCurrentLocation() {
		CustomLocation cl = new CustomLocation();
		return cl.getCurrentLocation();  // TODO
	}
}
